package com.zm.zyz.servlet;

import com.google.gson.Gson;
import com.zm.zyz.util.MyBatisHelper;
import com.zm.zyz.entity.ZyzTask;
import com.zm.zyz.mapper.ZyzTaskMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findTask")
public class FindTaskServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        ZyzTaskMapper taskMapper = MyBatisHelper.getSession().getMapper(ZyzTaskMapper.class);
        ZyzTask task = taskMapper.findById(id);
        Gson gson = new Gson();
        String json = gson.toJson(task);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().println(json);



    }
}
